//
//  SEGVisitorAccessTableViewCell.m
//  ExcellentHome
//
//  Created by 揭婧雯 on 2017/5/11.
//  Copyright © 2017年 陈区. All rights reserved.
//

#import "SEGVisitorAccessTableViewCell.h"
@interface SEGVisitorAccessTableViewCell() <UITextFieldDelegate>

@end

@implementation SEGVisitorAccessTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = kColor_W;
    
    UILabel *lable = [[UILabel alloc] init];
    lable.font = kFont_16;
    lable.textColor = kColor_1;
    [self.contentView addSubview:lable];
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(15);
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(85);
    }];
    self.lable = lable;
    
    UITextField *textField = [[UITextField alloc] init];
    textField.font = kFont_16;
    textField.textColor = kColor_1;
    textField.tintColor = kColor_T;
    textField.returnKeyType = UIReturnKeyDone;
    textField.delegate = self;
    [self.contentView addSubview:textField];
    [textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).mas_offset(110);
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).mas_offset(-30); 
        make.height.equalTo(self.contentView);
    }];
    self.textField = textField;
    
    UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:SEGPicName(@"btn_more_gray")]];
    [self.contentView addSubview:iconView];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).with.offset(-15);
        make.centerY.equalTo(self.contentView);
    }];
    self.selectImage = iconView;
}

#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
//    if ([[textField.text stringByReplacingCharactersInRange:range withString:string] length] > 20) return NO;
//     return YES;
//}

@end
